package com.hdax.dm.Service;

import com.hdax.dm.dto.base.AreaDto;
import com.hdax.dm.entity.base.Area;
import com.hdax.dm.feign.base.AreaFeign;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AreaService {

    @Autowired
    private AreaFeign areaFeign;

    public List<AreaDto> findArea(){
        List<Area> areas = areaFeign.findArea();
        List<AreaDto> areaDtos = new ArrayList<>();
        areas.forEach(area->{
            AreaDto areadto = new AreaDto();
            BeanUtils.copyProperties(area,areadto);
            areaDtos.add(areadto);
        });
        return areaDtos;
    }

}
